#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(kernel::test::test_runner)]
#![reexport_test_harness_main = "test_main"]

// 使用bootloader_api库提供的宏声明内核入口
bootloader_api::entry_point!(kernel_main);

/// 内核入口函数，参数为bootloader收集的硬件信息
fn kernel_main(boot_info: &'static mut bootloader_api::BootInfo) -> ! {
    kernel::init(boot_info);
    test_main();
    kernel::hlt_loop();
}

#[test_case]
fn test_chr2pixels() {
    use noto_sans_mono_bitmap::{get_raster, get_raster_width, FontWeight, RasterHeight};

    /// 字高
    const LETTER_HEIGHT: RasterHeight = RasterHeight::Size16;

    /// 字宽
    const _LETTER_WIDTH: usize = get_raster_width(FontWeight::Regular, LETTER_HEIGHT);

    /// 字体
    const FONT_WEIGHT: FontWeight = FontWeight::Regular;

    /// 待测字符
    const TEST_CHAR: char = 'E';

    // 字符转化为像素点
    let rendered_char =
        get_raster(TEST_CHAR, FONT_WEIGHT, LETTER_HEIGHT).expect("Failed to render a char");

    // 打印像素点
    kernel::serial_println!("");
    for (_y, row) in rendered_char.raster().iter().enumerate() {
        for (_x, byte) in row.iter().enumerate() {
            kernel::serial_print!("{:02x} ", *byte);
        }
        kernel::serial_println!("");
    }
}
